package com.yys.apm.controller;

import com.yys.apm.domain.User;
import com.yys.apm.entity.PubCity;
import com.yys.apm.service.ISayHello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author Yingsheng Ye
 */
@RestController
@RequestMapping("/hello")
@Validated
public class HelloController {

    @Autowired
    private ISayHello sayHello;

    @RequestMapping("/sayHello")
    public String sayHello(String name) {
        return sayHello.sayHello(name);
    }

    @RequestMapping("/pubCityList")
    public List<PubCity> pubCityList() {
        return sayHello.list();
    }

    @RequestMapping("/getUser")
    public String sayHello(@RequestBody User user) {
        return "name:" + user.getName() + ",age:" + user.getAge();
    }

    @RequestMapping("/getError")
    public void getError() {
        int i=1/0;
    }


}
